package Model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DataProvider {
	 public static String connectionString = "jdbc:sqlserver://localhost:1433;databaseName=QLWebsite2;user=SQL;password=123456";
	    
	    public static Connection Connection()
	    {
	        Connection con = null;
	        try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");   
	            con = DriverManager.getConnection(connectionString);
	            return con;
	        } catch (ClassNotFoundException | SQLException ex) {
	        }
	        return con;
	    }
	    
	    public static boolean Successful()
	    {
	        Connection con = null;
	        try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");   
	            con = DriverManager.getConnection(connectionString);
	            if(con != null){
	                con.close();
	                return true;
	            }
	        } catch (ClassNotFoundException | SQLException ex) {
	        	System.out.print(ex);
	            return false;
	        }
	        return false;
	    }
}
